package com.kaigejava.template.lifetemplate;

import java.util.Arrays;

/**
 * Created by kaigejava on 2019/9/5.
 */
public class SortTest {
    public static void main(String[] args) {
        Duck d1 = new Duck("Jack",(int)(Math.random()*10));
        Duck d2 = new Duck("Tom",(int)(Math.random()*10));
        Duck d3 = new Duck("Json",(int)(Math.random()*10));
        Duck [] ducks = new Duck[]{d1,d2,d3};
        System.out.println("==排序之前==");
        souArr(ducks);
        Arrays.sort(ducks);
        System.out.println("***排序之后***");
        souArr(ducks);
    }

    /**
     * 输出
     * @param ducks
     */
    private static void souArr(Duck[] ducks) {
        int len = ducks.length;
        for(int i=0;i<len;i++){
            System.out.println(ducks[i].toString());
        }
    }
}
